from prompts.LoadHisory import loadHistory
from app.parameter import PuttyChatParam
from langchain_core.messages import SystemMessage, AIMessage, HumanMessage

PUTTY_CHAT_PROMPT_HEADER="现在你作为一名`AI助手`，回答`人类`提出的问题，如果回答涉及代码，需要用`Markdown`格式给出，现在给出你与人类的对话列表，你需要结合上下文来给出问题答案：\n\n"

MAX_TOKEN = 32000
def getPuttyCharInput(data: PuttyChatParam, offical: bool = False):
    if offical:
        history = loadHistory(data.history, offical=True)
        history.append(HumanMessage(content=data.question))
        history.insert(0,SystemMessage(content=PUTTY_CHAT_PROMPT_HEADER))
        return history
                
    history = loadHistory(data.history)
    history += "\n\n人类的问题：" + data.question 
    return PUTTY_CHAT_PROMPT_HEADER + history

